package com.sunwayworld.basemodule.business.pjresultedithistory.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.business.pjresultedithistory.dao.LimsPjResultHistoryDao;
import com.sunwayworld.basemodule.business.pjresultedithistory.bean.LimsPjResultHistoryBean;
import com.sunwayworld.basemodule.business.pjresultedithistory.service.LimsPjResultHistoryService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsPjResultHistoryServiceImpl implements LimsPjResultHistoryService {

    @Autowired
    private LimsPjResultHistoryDao limsPjResultHistoryDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsPjResultHistoryDao getDao() {
        return limsPjResultHistoryDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsPjResultHistoryBean limsPjResultHistory = jsonWrapper.parseUnique(LimsPjResultHistoryBean.class);
        limsPjResultHistory.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsPjResultHistory);
        return limsPjResultHistory.getId();
    }

}
